package org.wyl.job51.component;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.wyl.job51.config.Job51Config;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.scheduler.Scheduler;

/**
 * @author: Mask.m
 * @create: 2021/07/14 20:56
 * @description: 爬虫启动
 */
@Component
public class JobSpiderStarter {

    private static Spider spider;

    public static void start() {
        spider = Spider.create(new JobPageProcessor())
                .addUrl(Job51Config.url)
                .addPipeline(new JobPipeline());
//                .setScheduler(scheduler);
        spider.start();
    }

    public static void stop() {
        if(null != spider){
            spider.stop();
        }
    }

}